package com.deco.logic.sys;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;

import com.deco.dao.delegate.brand.IBrandStoryDao;
import com.deco.dao.delegate.sys.ICmsAdvDao;
import com.deco.dao.delegate.sys.ICmsAdvTypeDao;
import com.deco.domain.vo.brand.BrandStoryVo;
import com.deco.domain.vo.product.PartsCategoryVo;
import com.deco.domain.vo.sys.CmsAdvTypeVo;
import com.deco.domain.vo.sys.CmsAdvVo;
import com.free.common.vo.PageResponseVo;
import com.free.common.vo.PageSearchVo;

/**
 * <p>
 * 功能概述:
 * </p>
 * <p>
 * 功能详述:
 * </p>
 */
@Component
public class CmsAdvTypeLogic {
    /*========================================================================*
     *                         Public Fields (公共属性)
     *========================================================================*/

    /*========================================================================*
     *                         Private Fields (私有属性)
     *========================================================================*/
    
    @Autowired
    ICmsAdvTypeDao cmsAdvTypeDao;

    /*========================================================================*
     *                         Construct Methods (构造方法)
     *========================================================================*/

    /*========================================================================*
     *                         Public Methods (公有方法)
     *========================================================================*/
	@Cacheable(value = "cmsAdvType",key = "#code")
    public CmsAdvTypeVo selectByCode(String code){
		CmsAdvTypeVo cmsAdvTypeVo = new CmsAdvTypeVo();
		cmsAdvTypeVo.setCode(code);
    	return cmsAdvTypeDao.selectOne(cmsAdvTypeVo);
	}

	@Cacheable(value = "cmsAdvType",key = "#id")
	public CmsAdvTypeVo getCmsAdvType(int id) {
		CmsAdvTypeVo cmsAdvTypeVo = new CmsAdvTypeVo();
		cmsAdvTypeVo.setId(id);
		return cmsAdvTypeDao.selectOne(cmsAdvTypeVo);
	}

	@CacheEvict(value = "cmsAdvType",allEntries = true)
	public void create(CmsAdvTypeVo cmsAdvTypeVo) {
		cmsAdvTypeDao.add(cmsAdvTypeVo);
		
	}

	@CacheEvict(value = "cmsAdvType",allEntries = true)
	public void update(CmsAdvTypeVo cmsAdvTypeVo) {
		cmsAdvTypeDao.update(cmsAdvTypeVo);
		
	}

	@CacheEvict(value = "cmsAdvType",allEntries = true)
	public void delete(int id) {
		cmsAdvTypeDao.delete(id);
	}

	@Cacheable(value = "cmsAdvType")
	public List<CmsAdvTypeVo> getAll() {
		CmsAdvTypeVo cond = new CmsAdvTypeVo();
		return cmsAdvTypeDao.selectList(cond , "");
	}

	public PageResponseVo<CmsAdvTypeVo> getPageInfo(PageSearchVo<CmsAdvTypeVo> condition) {
		return cmsAdvTypeDao.selectByPageNoNameLike(condition.getConditionVo(), " id desc ", condition.getCurrentNo(), condition.getLength());
	}

	@CacheEvict(value = "cmsAdvType",allEntries = true)
	public int batchDelete(Integer[] ids) {
		return cmsAdvTypeDao.batchDelete(ids);
	}

    /*========================================================================*
     *                         Private Methods (私有方法)
     *========================================================================*/
}
